package com.enjoy.bio;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;

/**
 * Created by HP on 2019/7/2.
 */
public class Client {
    public static void main(String[] args) throws IOException {
        Socket socket=null;

        ObjectOutputStream outputStream=null;
        ObjectInputStream inputStream=null;


        InetSocketAddress address=new InetSocketAddress("127.0.0.1",10001);

        socket=new Socket();
        try {
            socket.connect(address);
            outputStream =new ObjectOutputStream(socket.getOutputStream());
            inputStream =new ObjectInputStream(socket.getInputStream());


            outputStream.writeUTF("MARK");
            outputStream.flush();

            System.out.println(inputStream.readUTF());
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if (socket!=null){
                socket.close();
            }
            if (outputStream!=null){
                outputStream.close();
            }
            if (inputStream!=null){
                inputStream.close();
            }
        }
    }
}
